<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="admin/public/layout">

<head>
    <title>用户管理</title>
</head>
<div  layout:fragment="content">
    <section class="content-header">
        <h1>
            用户列表
            <small>显示当前系统的所有注册用户</small>
        </h1>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="row">
                            <div class="col-xs-3">
                                <div class="btn-group">
                                    <a th:href="@{/admin/user/create}" class="btn btn-default btn-sm" data-toggle="tooltip" title="创建新用户"><i class="fa fa-plus"></i></a>
                                    <button class="btn btn-default btn-sm" data-toggle="tooltip" title="通过审核" onclick="confirm_submit('item_form','/admin/user/verify','确认审核通过选中项？')"><i class="fa fa-check-square-o"></i></button>
                                    <button class="btn btn-default btn-sm" data-toggle="tooltip" title="删除选中项" onclick="confirm_submit('item_form','/admin/user/destroy','确认删除选中项？')"><i class="fa fa-trash-o"></i></button>
                                </div>
                            </div>
                            <div class="col-xs-9">
                                <div class="row">
                                    <form id="searchForm" th:action="@{/admin/user}" method="GET">
                                        <input th:name="page" th:value="${page}" type="hidden"/>
                                        <input th:name="size" th:value="${size}" type="hidden"/>
                                        <div class="col-xs-2 hidden-xs">
                                            <input type="text" class="form-control" name="uid" placeholder="UID" th:value="${condition.uid}"/>
                                        </div>
                                        <div class="col-xs-3 hidden-xs">
                                            <input type="text" class="form-control" name="usernameOrEmailOrMobile" placeholder="用户名|邮箱|手机号" th:value="${condition.usernameOrEmailOrMobile}"/>
                                        </div>
                                        <div class="col-xs-2 hidden-xs" >
                                            <select class="form-control" name="status">
                                                <option th:each="status:${UserStatus}" th:value="${status}" th:text="${status.name}" th:selected="${status} == ${condition.status}"   > </option>
                                            </select>
                                        </div>
                                        <div class="col-xs-2 hidden-xs">
                                            <input type="text" name="createdAtStart" class="form-control form_datetime" placeholder="注册起始时间"  th:value="${#dates.format(condition.createdAtStart,'yyyy-MM-dd HH:mm')}" />
                                        </div>
                                        <div class="col-xs-2 hidden-xs">
                                            <input type="text" name="createdAtEnd" class="form-control form_datetime" placeholder="注册结束时间" th:value="${#dates.format(condition.createdAtEnd,'yyyy-MM-dd HH:mm')}" />
                                        </div>
                                        <div class="col-xs-1">
                                            <button type="submit" class="btn btn-primary">搜索</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box-body  no-padding">
                        <form name="itemForm" id="item_form" method="POST">
                            <div class="table-responsive">
                                <table class="table table-striped">
                                    <tr>
                                        <th><input type="checkbox" class="checkbox-toggle"/></th>
                                        <th>用户ID</th>
                                        <th>用户名</th>
                                        <th>邮箱</th>
                                        <th>身份职业</th>
                                        <th>地区</th>
                                        <th>注册时间</th>
                                        <th>更新时间</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                    <tr th:each="user:${users.content}">
                                        <td><input type="checkbox" th:value="${user.id}" name="id"/></td>
                                        <td th:text="${user.id}"></td>
                                        <td th:text="${user.nickname}"></td>
                                        <td th:text="${user.email}"></td>
                                        <td th:text="${user.detail?.title}"></td>
                                        <td>
                                            <span th:if="${user.detail?.province}" th:text="${user.detail?.province}"></span>
                                            <span th:if="${user.detail?.city}" th:text="${user.detail?.city}"></span>
                                        </td>
                                        <td th:text="${#dates.format(user.createdAt,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td th:text="${#dates.format(user.updatedAt,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td><span th:text="${user.status.name}" th:class="${user.status == UserStatus.REVIEW_PENDING}?'label label-default':((${user.status==UserStatus.REVIEW_REJECT}?'label label-danger': 'label label-success')) "></span> </td>
                                        <td>
                                            <div class="btn-group-xs" >
                                                <a class="btn btn-default" th:href="'/admin/user/'+${user.id}" data-toggle="tooltip" title="编辑用户信息"><i class="fa fa-edit"></i></a>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </form>
                    </div>
                    <div class="box-footer clearfix">
                        <div class="row">
                            <div class="col-sm-3">
                                <div class="btn-group">
                                    <a th:href="@{/admin/user/create}" class="btn btn-default btn-sm" data-toggle="tooltip" title="创建新用户"><i class="fa fa-plus"></i></a>
                                    <button class="btn btn-default btn-sm" data-toggle="tooltip" title="通过审核" onclick="confirm_submit('item_form','/admin/user/verify','确认审核通过选中项？')"><i class="fa fa-check-square-o"></i></button>
                                    <button class="btn btn-default btn-sm" data-toggle="tooltip" title="删除选中项" onclick="confirm_submit('item_form','/admin/user/destroy','确认删除选中项？')"><i class="fa fa-trash-o"></i></button>
                                </div>
                            </div>
                            <div class="col-sm-9">
                                <div class="text-right" layout:include="admin/public/pagination :: pagination" th:with="condition=${condition}, page=${users},formSelecter='#searchForm',pageParmName='page'">

                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </section>
</div>